package thread.processing.performance;

import java.math.BigInteger;

public class FactorialTest {

	public static void main(String[] args) {
		for (int i = 1; i <= 1000; i++) {
			System.out.println("Factorial of " + i + " is " + bigFactorial(i));
		}
		/*
		 * System.out.println(factorial(1)); System.out.println(factorial(5));
		 * System.out.println(factorial(10));
		 */

	}

	public static long smallFactorial(long n) {
		if (n <= 1) {
			return 1;
		} else {
			return n * smallFactorial(n - 1);
		}
	}
	public static BigInteger bigFactorial(long n) {
		if (n <= 1) {
			// 1
			return new BigInteger("1");
		} else {
			// n * factorial(n - 1)
			return BigInteger.valueOf(n).multiply(bigFactorial(n - 1));
		}
	}
}
